home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Windows Selection / Windows Selection 1.iso / Programmer's Utilities / IntelliBots / IBOTS / SEEKER1.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-07-26  |  7.3 KB  |  250 lines

  1. ;******************************************************
  2. ;TITLE:        SEEKER1.ASM
  3. ;CREATED BY:   Intelligent Technologies
  4. ;DESCRIPTION:  This program makes an IBot wander around and
  5. ;              then search for a target
  6. ;NOTES:        This program supports a more advanced hunt algorithm
  7. ;              so that if an aquired target moves an attempt is made
  8. ;              to relocate it
  9. ;Name             Date          Description
  10. ;---------------- ------------- -------------------
  11. ;ITI              July 22, 1995 created the program
  12. ;******************************************************
  13.  
  14.     .NAME    "Seeker1"
  15.  
  16.  
  17. ;******************************************************
  18. ; Start
  19. ;
  20. ; DESC:   This is the starting point for the program
  21. ; IN:     nothing
  22. ; OUT:    nothing
  23. ; NOTES:  nothing
  24. Start
  25.     MOVE    #-1,R6                ;initialize the turret direction storage
  26.     CALL    Wander                ;wander someplace else
  27.     CALL    Hunt                ;hunt for an enemy ibot
  28.     JUMP    Start
  29.  
  30.  
  31. ;******************************************************
  32. ; Fire
  33. ;
  34. ; DESC:   Fire laser at enemy IBot
  35. ; IN:     nothing
  36. ; OUT:    nothing
  37. ; NOTES:  This routine assumes that the turret is already
  38. ;         pointing in the correct direction,  also this
  39. ;         routine destroys the contents of R0 and R1
  40. Fire
  41.     GETP    #LASERTEMP,R0        ;get the current laser temperature
  42.     JL        FireLaserDead        ;-laser is burned out
  43.     MOVE    #LASERMELTTEMP,R1    ;get the burn out power
  44.     SUB        R0,R1                ;subtract the current temperature
  45.     CMP        #25,R1                ;is laser cool enough to fire
  46.     JLE        FireExit            ;-laser too hot to fire
  47.     COPR    #OFFENSELASER,R1    ;fire the laser
  48. FireExit
  49.     RTS
  50. FireLaserDead
  51.     LEA        LaserDeadStr,R0
  52.     SYS        #STATUSTEXT,R0
  53.     HALT
  54.     
  55.  
  56. ;******************************************************
  57. ; Hunt
  58. ;
  59. ; DESC:   Search for an enemy IBot
  60. ; IN:     nothing
  61. ; OUT:    nothing
  62. ; NOTES:  This routine scans in a complete circle searching for
  63. ;         a target, and destroys the contents of R0, R1, R5 and R6
  64. Hunt
  65.     MOVE    #360,R0                ;init the max sweep
  66. HuntLoop
  67.     COPR    #TURRETSCAN,#0        ;scan in current direction
  68.     GETP    #SCANDISTANCE,R5    ;get the distance to the scanned object
  69.     GETP    #SCANOBJECT,R1        ;get the object scanned
  70.     JLE        HuntNext            ;-nothing, do next
  71.     CMP        #IBOT1,R1            ;is the object an IBot?
  72.     JL        HuntNotIBot            ;-not an IBot
  73.     CMP        #IBOT4,R1            ;is the object an IBot?
  74.     JLE        HuntFoundIbot        ;-yes
  75. HuntNotIBot
  76.     MOVE    #5,R1                ;set the standard sweep increment
  77.     CMP        #8,R5                ;was the terrain close
  78.     JG        HuntTurn            ;-not close enough to wory about
  79.     MOVE    #15,R1                ;set faster sweep increment
  80. HuntTurn
  81.     SUB        R1,R0                ;decrement the total sweep
  82.     JLE        HuntExit            ;-done
  83.     COPR    #TURRETTURN,R1        ;turn the turret to new scan direction
  84.     JUMP    HuntLoop            ;-scan again
  85. HuntNext
  86.     MOVE    #5,R1                ;set standard sweep increment
  87.     JUMP    HuntTurn            ;-turn the turret
  88. HuntFoundIbot
  89.     GETP    #TURRETDIR,R6        ;get the turret direction
  90.     CALL    Fire                ;fire at the ibot
  91.     CALL    Scan                ;scan for it again
  92.     JUMP    Hunt                ;-begin a new hunt
  93. HuntExit
  94.     RTS
  95.  
  96.  
  97. ;******************************************************
  98. ; Move
  99. ;
  100. ; DESC:   Move the IBot
  101. ; IN:     R0 = absolute angle to turn to before moving
  102. ;         R1 = distance to move
  103. ; OUT:    nothing
  104. ; NOTES:  nothing
  105. Move
  106.     PUSH    R0                    ;save r0
  107.     PUSH    R1                    ;save r1
  108.     PUSH    R2                    ;save r2
  109.     GETP    #CHASSISDIR,R2        ;get the current chassis direction
  110.     SUB        R2,R0                ;calculate the amount to turn
  111.     JE        MoveMove            ;-don't need to turn, check distance to move
  112.     COPR    #CHASSISTURN,R0        ;turn the chassis
  113. MoveMove
  114.     SUB        #2,R1                ;how far do we need to move
  115.     JLE        MoveExit            ;-don't need to move, exit
  116.     COPR    #CHASSISMOVE,R1        ;move the ibot
  117. MoveExit
  118.     POP        R2                    ;restore r2
  119.     POP        R1                    ;restore r1
  120.     POP        R0                    ;restore r0
  121.     RTS
  122.  
  123.  
  124. ;******************************************************
  125. ; Scan
  126. ;
  127. ; DESC:   Scan for an enemy and move closer if necessary
  128. ; IN:     nothing
  129. ; OUT:    nothing
  130. ; NOTES:  This routine assumes that the turret is already
  131. ;         pointing in the correct direction,  also this
  132. ;         routine destroys the contents of R0, R1, R5 and R6
  133. Scan
  134.     COPR    #TURRETSCAN,#0        ;scan for enemy ibot
  135.     GETP    #SCANOBJECT,R0        ;get the scan results
  136.     JLE        ScanCheckExit        ;-nothing
  137.     MOVE    R0,R1                ;save the scan result
  138.     CMP        #IBOT1,R1            ;is the object an IBot?
  139.     JL        ScanCheckExit        ;-not an IBot
  140.     CMP        #IBOT4,R1            ;is the object an IBot?
  141.     JG        ScanCheckExit        ;-yes
  142.     GETP    #TURRETDIR,R6        ;get the turret direction
  143.     GETP    #SCANDISTANCE,R5    ;get the distance to the enemy
  144. ScanCheckFire
  145.     CMP        #20,R5                ;are we closer than 20
  146.     JG        ScanMoveCloser        ;-no, move closer
  147.     CALL    Fire                ;fire at the ibot
  148.     JUMP    Scan                ;-go scan again
  149. ScanMoveCloser
  150.     MOVE    R6,R0                ;set the angle to turn to
  151.     MOVE    R5,R1                ;set the distance to move
  152.     LSR        #1,R1                ;calculate what half the distance would be
  153.     CALL    Move                ;move the ibot
  154.     CALL    TurnTurret            ;turn the turret
  155.     JUMP    Scan                ;-go scan again
  156. ScanCheckExit
  157.     CMP        #-1,R6
  158.     JE        ScanExit
  159.     CALL    Search
  160.     JPL        ScanCheckFire
  161. ScanExit
  162.     RTS
  163.     
  164.  
  165. ;******************************************************
  166. ; Search
  167. ;
  168. ; DESC:   Search for enemy after it moves
  169. ; IN:     nothing
  170. ; OUT:    R5 = distance to scanned object/terrain
  171. ;         R6 = direction to scanned object/terrain
  172. ; NOTES:  This routine assumes that the turret is pointing
  173. ;         in the direction the enemy was last seen,  also this
  174. ;         routine destroys the contents of R0 and R1
  175. Search
  176.     MOVE    #18,R0                ;initialize scan count
  177.     COPR    #TURRETTURN,#-45    ;turn the turret -45 degrees
  178.     JUMP    SearchDoScan
  179. SearchTryAgain
  180.     DEC        R0                    ;decrement count and check if it is negative
  181.     JL        SearchFailed        ;-if count is negative, search failed
  182.     COPR    #TURRETTURN,#5        ;turn the turret 5 degrees
  183. SearchDoScan
  184.     COPR    #TURRETSCAN,#0        ;scan
  185.     GETP    #SCANOBJECT,R1        ;get the scan result
  186.     JLE        SearchTryAgain        ;-if nothing, try again
  187.     CMP        #IBOT1,R1            ;is the object an IBot?
  188.     JL        SearchTryAgain        ;-not an IBot
  189.     CMP        #IBOT4,R1            ;is the object an IBot?
  190.     JG        SearchTryAgain        ;-yes
  191.     GETP    #TURRETDIR,R6        ;get the turret direction
  192.     GETP    #SCANDISTANCE,R5    ;get the scan distance
  193.     RTS
  194. SearchFailed
  195.     MOVE    #-1,R6                ;set the direction to not found
  196.     RTS
  197.  
  198.  
  199. ;******************************************************
  200. ; TurnTurret
  201. ;
  202. ; DESC:   Turn the IBot turret
  203. ; IN:     R0 = absolute angle to turn the turret to
  204. ; OUT:    nothing
  205. ; NOTES:  nothing
  206. TurnTurret
  207.     PUSH    R0                    ;save r0
  208.     PUSH    R2                    ;save r2
  209.     GETP    #TURRETDIR,R2        ;get the current turret direction
  210.     SUB        R2,R0                ;calculate the amount to turn
  211.     JE        TurnTurretExit        ;-don't need to turn, check distance to move
  212.     COPR    #TURRETTURN,R2        ;turn the chassis
  213. TurnTurretExit
  214.     POP        R2                    ;restore r2
  215.     POP        R0                    ;restore r0
  216.     RTS
  217.  
  218.  
  219. ;******************************************************
  220. ; Wander
  221. ;
  222. ; DESC:   Make the IBot wander
  223. ; IN:     nothing
  224. ; OUT:    nothing
  225. ; NOTES:  This routine destroys the contents of R0 and R1
  226. Wander
  227.     COPR    #TURRETSCAN,#0        ;scan in the current turret direction
  228.     GETP    #SCANOBJECT,R0        ;get the object scanned
  229.     JLE        WanderNothing        ;-nothing, ok to move
  230.     CMP        #IBOT1,R0            ;is the object an IBot?
  231.     JL        WanderExit            ;-not an IBot
  232.     CMP        #IBOT4,R0            ;is the object an IBot?
  233.     JG        WanderExit            ;-yes
  234.     GETP    #SCANDISTANCE,R0    ;get the distance to the scanned object
  235.     CMP        #10,R0                ;is there room to move
  236.     JLE        WanderNew            ;-no room, check for a new direction
  237. WanderNothing
  238.     GETP    #TURRETDIR,R0        ;get the turret direction
  239.     MOVE    #20,R1                ;set the distance
  240.     CALL    Move                ;move the ibot
  241. WanderExit
  242.     RTS
  243. WanderNew
  244.     COPR    #TURRETTURN,#10        ;turn the turret
  245.     JUMP    Wander                ;-check the new direction
  246.  
  247.  
  248. LaserDeadStr
  249.     DSTR    "Laser burned out!"
  250.